package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.SignUpCharge;
import com.eling.elcms.travel.model.view.SignUpChargeSaveView;
import com.eling.elcms.travel.model.view.SignUpChargeView;
import com.eling.elcms.travel.model.view.SignUpFeeView;
import com.eling.elcms.travel.service.ISignUpChargeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
public class SignUpChargeController extends BaseFormController {

	@Autowired
	private ISignUpChargeManager signUpChargeManager;

	@RequestMapping("/api/signupcharge/save")
	@ResponseBody
	public SignUpCharge save(@ModelAttribute @ModelFilling SignUpCharge cond) {
		return signUpChargeManager.save(cond);
	}

	@RequestMapping("/api/signupcharge/query")
	@ResponseBody
	public List<SignUpCharge> query(@ModelAttribute SignUpCharge cond) {
		return signUpChargeManager.query(cond);
	}
	
	@RequestMapping("/api/signupcharge/queryplan")
	@ResponseBody
	public List<SignUpFeeView> queryPlan(@ModelAttribute SignUpCharge cond) {
		return signUpChargeManager.queryPlan(cond);
	}

	@RequestMapping("/api/signupcharge/search*")
	@ResponseBody
	public List<SignUpCharge> search(@ModelAttribute SearchCondition sc,
			@ModelAttribute SignUpCharge cond) {
		sc.setQueryCondition(cond);
		return signUpChargeManager.search(sc);
	}

	/**
	 * 查询报名收费列表数据
	 * @param cond
	 * @param status
	 * @param pkServicePoint
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/signupcharge/queryplanitem")
	@ResponseBody
	public List<SignUpChargeView> queryPlanItem(
			@RequestParam(value = "pkDestination", required = false) Long pkDestination,
			@RequestParam(value = "startDate", required = false) Date startDate,
			@RequestParam(value = "startDateEnd", required = false) Date startDateEnd,
			@RequestParam(value = "planStatus", required = false) String planStatus,
			@RequestParam(value = "pkServicePoint", required = false) Long pkServicePoint) {
		return signUpChargeManager.queryPlanItem(pkServicePoint, pkDestination,
				startDate, startDateEnd, planStatus);
	}

	/**
	 * 报名登记点击收费跳转收费界面查询数据
	 * @param pkPlanItem
	 * @param pkServicePoint
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/signupcharge/queryplanitembypk")
	@ResponseBody
	public List<SignUpChargeView> queryPlanItemByPk(
			@RequestParam(value = "pkPlanItem", required = false) Long pkPlanItem,
			@RequestParam(value = "pkServicePoint", required = false) Long pkServicePoint) {
		return signUpChargeManager.queryPlanItemByPk(pkPlanItem, pkServicePoint);
	}

	@RequestMapping("/api/signupcharge/savecharge")
	@ResponseBody
	public List<SignUpCharge> saveCharge(@ModelAttribute SignUpChargeSaveView sucsView) {
		return signUpChargeManager.saveCharge(sucsView);
	}
	
	
}
